// UVa11440 Help Mr. Tomisu
// 刘汝佳
#include <bits/stdc++.h>
using namespace std;
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
typedef long long LL;
const LL MOD = 1e8 + 7;
const int MAXM = 1e7 + 4, MAXP = MAXM + 4;
LL PF[MAXM + 4];  // p[i]:phi(N!)
bool isPrime[MAXP];
vector<int> primes;  // primes
void sieve() {       // 素数筛法
  fill_n(isPrime, MAXP, true);
  _for(i, 2, MAXP) if (isPrime[i]) {
    LL j = i;
    for (j *= i; j < MAXP; j += i) isPrime[j] = false;
    primes.push_back(i);
  }
}

void init() {  // 初始化φ(N!)
  sieve();
  PF[1] = 1, PF[2] = 1;
  _rep(n, 3, MAXM) {
    if (isPrime[n])
      PF[n] = (n - 1) * PF[n - 1];
    else
      PF[n] = n * PF[n - 1];
    PF[n] %= MOD;
  }
}

int main() {
  init();
  for (LL N, M; scanf("%lld%lld", &N, &M) == 2 && N && M;) {
    LL ans = 1;
    _rep(i, M + 1, N) ans = (ans * i) % MOD;
    ans = (ans * PF[M] - 1) % MOD;
    printf("%lld\n", ans);
  }
}
/*
算法分析请参考: 《入门经典-第2版》例题 10-26
*/
// 24515052 11440 Help Tomisu Accepted C++11 0.210 2020-02-05 12:39:52